package com.lv.dhart.ui.fragment.fghome.juhe.news.base;

import android.view.View;

import com.lv.dhart.R;
import com.lv.dhart.base.AbsTopNavigationTabBaseFragment;
import com.lv.dhart.beans.JuheNewsBean;
import com.lv.dhart.callback.DataCallback;
import com.lv.dhart.ui.fragment.fghome.juhe.news.JuheViewHolderHelper;
import com.smart.holder.iinterface.IViewHolderHelper;

import java.util.ArrayList;

/**
 * Created by binny on 2018/6/8.
 * <p>
 * 聚合数据
 */

public class NewsJuHeFragment extends AbsTopNavigationTabBaseFragment implements DataCallback<JuheNewsBean> {


    protected String mType;
    private ArrayList<JuheNewsBean.ResultBean.DataBean> mDataBeanList = new ArrayList<>();

    @Override
    protected void initRefreshView(View containerView) {
        super.initRefreshView(containerView);
        mRefreshLayout.setEnableLoadMore(false);
//        mRefreshLayout.setEnableRefresh(false);

    }

    @Override
    protected IViewHolderHelper initViewHolderHelper() {
        return new JuheViewHolderHelper();
    }

    @Override
    protected int initItemLayout() {
        return R.layout.item_fragment_base_info;
    }

    @Override
    protected ArrayList<JuheNewsBean.ResultBean.DataBean> initListBean() {
        return mDataBeanList;
    }


    @Override
    protected void getData() {
        //优先加载本地数据
        if (loadLocal()) {
            return;
        }

        //从网络上加载数据
    }


    @Override
    public void onError(String result) {
        mRefreshLayout.finishRefresh(false);
        mRefreshLayout.finishLoadMore(false);
        loadLocal();
    }

    /**
     * @return {@code false 加载本地数据失败}
     */
    private boolean loadLocal() {
        return false;
    }

    @Override
    public void onLoading() {
    }

    @Override
    public void onLoadDone() {

    }


    @Override
    public void onSuccess(JuheNewsBean juheNewsBean) {
        mCommonAdapter.notifyDataSetChanged();

    }

    @Override
    protected void onRefresh() {

    }

    @Override
    protected void onLoadMore() {

    }
}
